package com.aiyige.page.publish.learnvideo;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.arouter.config.ARouterConfig;
import com.aiyige.page.publish.util.PublishUtil;
import com.aiyige.utils.DialUtil;
import com.aiyige.utils.StringUtils;
import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

@Route(path = ARouterConfig.PublishLearnVideoResultPage)
public class PublishLearnVideoResultPage extends AppCompatActivity {

    @BindView(R.id.titleTv)
    TextView titleTv;
    @BindView(R.id.imageView)
    ImageView imageView;
    @BindView(R.id.textView)
    TextView textView;
    @Autowired
    int publishOperationType;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.page_publish_learn_video_result);
        ButterKnife.bind(this);
        ARouter.getInstance().inject(this);
        switch (publishOperationType) {
            case PublishUtil.PUBLISH_OPERATION_TYPE_EDIT_SAVE:
            case PublishUtil.PUBLISH_OPERATION_TYPE_SAVE:
                titleTv.setText(R.string.save_only);
                textView.setText(R.string.saving_video);
                imageView.setImageResource(R.drawable.uploading);
                break;
            case PublishUtil.PUBLISH_OPERATION_TYPE_EDIT_SUBMIT_REIVEW:
            case PublishUtil.PUBLISH_OPERATION_TYPE_SUBMIT_REVIEW:
                titleTv.setText(R.string.submit_for_approval);
                textView.setText(R.string.we_will_finish_review_in_two_days);
                imageView.setImageResource(R.drawable.examine);
                break;
        }
    }

    @OnClick({R.id.backToHomePageBtn, R.id.merchandiseManagementBtn, R.id.contactLayout})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.backToHomePageBtn:
                ARouter.getInstance()
                        .build(ARouterConfig.MainPage)
                        .withFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
                        .navigation(this);
                finish();
                break;
            case R.id.merchandiseManagementBtn:
                ARouter.getInstance()
                        .build(ARouterConfig.MerchandiseManagementPage)
                        .navigation();
                finish();
                break;
            case R.id.contactLayout:
                DialUtil.dial(StringUtils.getString(R.string.customer_service_number));
                break;
        }
    }
}
